<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2020/5/13 0013
  Time: 18:02
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%String path = request.getContextPath();%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<jsp:include page="../../inc/header.jsp"></jsp:include>
<!-- Page Heading Section Start -->
<div class="page-heading-section section bg-parallax" data-bg-image="<%=path%>/assets/images/bg/bg-1.jpg" data-overlay="50">
    <div class="container">
        <div class="page-heading-content text-center">
            <h2 class="title">修改岗位信息</h2>
            <ol class="breadcrumb">
                <li class="breadcrumb-item"><a href="<%=path%>/web/index">网站首页</a></li>
            </ol>
        </div>
    </div>
</div>
<!-- Page Heading Section End -->
<!-- Create Job Start -->
<div class="section section-padding">
    <div class="container">
        <div class="row">
            <div class="create-job-form col-lg-10 mx-auto">
                <c:if test="${'success' eq param.msg}">
                    <img src="<%=path%>/assets/images/app/success.png" width="300"><font style="font-size: 50px">岗位信息修改成功</font>"
                </c:if>
                <c:if test="${param.msg eq null}">
                    <form action="<%=path%>/web/company/manage/position/update" method="post" id="myForm">
                        <div class="row mb-n3">
                            <div class="col-md-6 col-12 mb-3">
                                <label for="name">职位名称</label>
                                <input type="hidden" name="id" value="${companyPosition.id}">
                                <input type="text" id="name" value="${companyPosition.name}" name="name" placeholder="列如 Java软件开发工程师">
                            </div>
                            <div class="col-md-6 col-12 mb-3">
                                <label for="positionAttr">工作性质</label>
                                <select id="positionAttr" name="positionAttrId">
                                    <c:forEach items="${positionAttrList}" var="positionAttr">
                                        <c:if test="${positionAttr.id eq companyPosition.positionAttr.id}">
                                            <option selected="selected" value="${positionAttr.id}">${positionAttr.attr}</option>
                                        </c:if>
                                        <c:if test="${positionAttr.id ne companyPosition.positionAttr.id}">
                                            <option value="${positionAttr.id}">${positionAttr.attr}</option>
                                        </c:if>
                                    </c:forEach>
                                </select>
                            </div>
                            <div class="col-md-6 col-12 mb-3">
                                <label for="salaryMin">最低薪资</label>
                                <input type="text" value="${companyPosition.salaryMin}" id="salaryMin" name="salaryMin" placeholder="6000">
                            </div>
                            <div class="col-md-6 col-12 mb-3">
                                <label for="salaryMax">最高薪资</label>
                                <input type="text" value="${companyPosition.salaryMax}" id="salaryMax" name="salaryMax" placeholder="8000">
                            </div>
                            <div class="col-md-6 col-12 mb-3">
                                <label for="city">工作城市</label>
                                <input type="text" placeholder="青岛" value="${companyPosition.city.cityName}" name="cityName" id="city">
                            </div>
                            <div class="col-md-6 col-12 mb-3">
                                <label for="workTime">工作经验</label>
                                <select id="workTime" name="workTimeId">
                                    <c:forEach items="${workTimeList}" var="workTime">
                                        <c:if test="${workTime.id eq companyPosition.workTime.id}">
                                            <option selected="selected" value="${workTime.id}">${workTime.workExpTime}</option>
                                        </c:if>
                                        <c:if test="${workTime.id ne companyPosition.workTime.id}">
                                            <option value="${workTime.id}">${workTime.workExpTime}</option>
                                        </c:if>
                                    </c:forEach>
                                </select>
                            </div>
                            <div class="col-md-6 col-12 mb-3">
                                <label for="educationalBackgroundType">学历要求</label>
                                <select id="educationalBackgroundType" name="educationalBackgroundTypeId">
                                    <c:forEach items="${educationalBackgroundTypeList}" var="edu">
                                        <c:if test="${edu.id eq companyPosition.educationalBackgroundType.id}">
                                            <option selected="selected" value="${edu.id}">${edu.educationalBackgroundTypeName}</option>
                                        </c:if>
                                        <c:if test="${edu.id ne companyPosition.educationalBackgroundType.id}">
                                            <option value="${edu.id}">${edu.educationalBackgroundTypeName}</option>
                                        </c:if>
                                    </c:forEach>
                                </select>
                            </div>
                            <div class="col-12 mb-3">
                                <label for="skillRequest">技能要求</label>
                                <textarea id="skillRequest" name="skillRequest" rows="5">${companyPosition.skillRequest}</textarea>
                            </div>
                            <div class="col-12 mb-3">
                                <label for="positionDescription">职位描述</label>
                                <textarea id="positionDescription" name="positionDescription" rows="5">${companyPosition.positionDescription}</textarea>
                            </div>

                            <div class="col-12 mb-3">
                                <input type="button" id="mybtn" class="btn btn-primary px-5" value="修改"></input>
                                <span id="msg" style="color: red"></span>
                            </div>
                        </div>
                        <div class="row"></div>
                    </form>
                </c:if>
            </div>
        </div>
    </div>
</div>
<!-- Create Job End -->
<script type="text/javascript" src="<%=path%>/assets/js/vendor/jquery-3.4.1.min.js"></script>
<script type="text/javascript">
    $(function () {

        var mybtn = $("#mybtn");
        mybtn.click(function () {
            $("#msg").html("");
            var city = $.trim($("#city").val());
            if(city==""){
                $("#msg").html("请填写工作城市");
                return;
            }
            var flag = 0;
            $.ajax({
                url:"<%=path%>/web/company/manage/position/checkCity",
                async:"false",
                data:"cityName="+city,
                success:function (mes) {
                    if(mes == "0"){
                        flag=1;
                        $("#msg").html("该城市未找到");
                    }
                }
            });
            if(flag==1){
                return;
            }
            var name = $.trim($("#name").val());
            if(name==""){
                $("#msg").html("请填写职位名称");
                return;
            }
            var salaryMax = $.trim($("#salaryMax").val());
            if(salaryMax==""){
                $("#msg").html("请填写最高薪资");
                return;
            }var salaryMin = $.trim($("#salaryMin").val());
            if(salaryMin==""){
                $("#msg").html("请填写最低薪资");
                return;
            }
            var skillRequest = $.trim($("#skillRequest").val());
            if(skillRequest==""){
                $("#msg").html("请填写技能要求");
                return;
            }
            var positionDescription = $.trim($("#positionDescription").val());
            if(positionDescription==""){
                $("#msg").html("请填写职位描述");
                return;
            }

            $("#msg").html("");
            $("#myForm").submit();

        });

    });
</script>

<jsp:include page="../../inc/footer.jsp"></jsp:include>